# coding:utf-8
# writingtime: 2022-8-1

class UCI:
    """
    UCI数据集
    """

    @staticmethod
    def haberman():
        """
        haberman数据集，属性数：3，数据个数：306，数据类型：整数
        web: http://archive.ics.uci.edu/ml/datasets/Haberman%27s+Survival
        :return: haberman数据集
        """
        f = open(r'..\ClusteringCode\UCI\Haberman.txt', 'r')
        data = []
        for i in f.readlines():
            # print([float(j) for j in i.split(',')[:-1]])
            data.append([float(j) for j in i.split(',')[:-1]])
        f.close()

        return data

    @staticmethod
    def heart():
        """
        Heart数据集，属性数：13，数据个数：270，数据类型：实数
        web：http://archive.ics.uci.edu/ml/datasets/Statlog+%28Heart%29
        :return:
        """
        f = open(r'..\ClusteringCode\UCI\Heart.txt', 'r')
        data = []
        for i in f.readlines():
            # print([float(j) for j in i.split(' ')[:-1]])
            data.append([float(j) for j in i.split(' ')[:-1]])
        f.close()

        return data

    @staticmethod
    def hfcr():
        """
        Hfcr数据集，属性数：13，数据个数：299，数据类型：实数
        web：http://archive.ics.uci.edu/ml/datasets/Heart+failure+clinical+records
        :return:Hfcr数据集
        """
        f = open(r'..\ClusteringCode\UCI\Hfcr.txt', 'r')
        data = []
        for i in f.readlines():
            # print([float(j) for j in i.split(',')[:-1]])
            data.append([float(j) for j in i.split(',')[:-1]])
        f.close()

        return data

    @staticmethod
    def htru2():
        """
        HTRU2数据集，属性数：9，数据个数：17898，数据类型：实数
        web：http://archive.ics.uci.edu/ml/datasets/HTRU2
        :return:
        """
        f = open(r'..\ClusteringCode\UCI\HTRU2.txt', 'r')
        data = []
        for i in f.readlines():
            # print([float(j) for j in i.split(',')])
            data.append([float(j) for j in i.split(',')[:-1]])
        f.close()

        return data

    @staticmethod
    def iris():
        """
        Iris数据集，属性数：4，数据个数：150，数据类型：实数
        web：http://archive.ics.uci.edu/ml/datasets/Iris
        :return:
        """
        f = open(r'..\ClusteringCode\UCI\Iris.txt', 'r')
        data = []
        for i in f.readlines():
            # print([float(j) for j in i.split(',')[:-1]])
            data.append([float(j) for j in i.split(',')[:-1]])
        f.close()
        return data

    @staticmethod
    def seeds():
        """
        Seeds数据集，属性数：7，数据个数：210，数据类型：实数
        web：http://archive.ics.uci.edu/ml/datasets/seeds
        :return:
        """
        f = open(r'..\ClusteringCode\UCI\Seeds.txt', 'r')
        data = []
        for i in f.readlines():
            # print([float(j) for j in i.split()[:-1]])
            data.append([float(j) for j in i.split()[:-1]])
        f.close()

        return data

    @staticmethod
    def segment():
        """
        segmention数据集，属性数：19，数据个数：2310，数据类型：实数
        web：http://archive.ics.uci.edu/ml/datasets/Image+Segmentation
        :return:
        """
        f = open(r'..\ClusteringCode\UCI\Segment.txt', 'r')
        data = []
        for i in f.readlines():
            # print([float(j) for j in i.split(',')[1:]])
            data.append([float(j) for j in i.split(',')[1:]])
        f.close()

        return data
